﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>公共区域监控地址添加</title>
<link rel="stylesheet" href="/scriptZIP/layui.min.css">
	<link rel="stylesheet" href="/css/common2.css">
	<link rel="stylesheet" href="/css/radio.css">
	<link rel="stylesheet" href="/css/layui.css" />
	<style>
		.layui-row {
			margin-top: 5px;
		}

		.return {
			margin-top: 0 !important;
		}
	</style>
</head>

<body>
	<div class="layui-row" id="vue-root">
		
		<div class="layui-col-md6 layui-col-md-offset3">

			<div class="layui-form-item">
				<label class="layui-form-label">设备序列号</label>
				<div class="layui-input-block">
					<input name="deviceSerial" v-validate="'required'" autocomplete="off" placeholder="请输入设备序列号"
						class="layui-input name" v-model="item.deviceSerial">
					<div class="checkout_state" v-text="err('deviceSerial')">
					</div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">通道号</label>
				<div class="layui-input-block">
					<input name="channelNo" v-validate="'required|numeric'" autocomplete="off" placeholder="请输入通道号"
						class="layui-input name" v-model="item.channelNo">
					<div class="checkout_state" v-text="err('channelNo')">
					</div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">安装位置</label>
				<div class="layui-input-block">
					<input v-validate="'required'" autocomplete="off" placeholder="请输入公共区域名称"
						class="layui-input introduction" v-model="item.area" name="publicArea">
					<div class="checkout_state" v-text="err('publicArea')"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">是否收费</label>
				<div class="layui-input-block true" style="padding-top: 13px;line-height: 15px;">
					<input type="radio" name="paid" :value="true" title="是" v-model="item.paid">
					<span>是</span>
					<input type="radio" name="paid" :value="false" title="否" v-model="item.paid"
						style="margin-left: 20px;">
					<span>否</span>
				</div>
			</div>

			<template v-if="item.paid">
				<div class="layui-form-item">
					<label class="layui-form-label">模式</label>
					<div class="layui-input-block true" style="padding-top: 13px;line-height: 15px;">
						<input type="radio" name="share" :value="false" title="是" v-model="item.share">
						<span>单独观看</span>
						<input type="radio" name="share" :value="true" title="否" v-model="item.share"
							style="margin-left: 20px;">
						<span>家庭共享</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">价格</label>
					<div class="layui-input-block">
						<input autocomplete="off" style="display: inline-block; width: 25% !important;margin-right: 3%;"
							placeholder="首次购买价格" class="layui-input introduction" v-model="initFee">
						<input autocomplete="off" style="display: inline-block; width: 25% !important;margin-left: 3%;"
							placeholder="续费价格" class="layui-input introduction" v-model="laterFee">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">服务天数</label>
					<div class="layui-input-block true" style="line-height: 15px;">
						<input autocomplete="off" placeholder="服务天数" v-model="item.duration" type="number"
							class="layui-input introduction">
					</div>
				</div>
			</template>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="button" class="offer" value="立即提交" @click="submit">
					<div class="return" onclick="history.back()">取消</div>
				</div>
			</div>
		</div>
	</div>
	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	
	
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/item.js"></script>

	<script>
		var app = new Vue(merge({
			data: {
				item: {
					schoolId: null,
					type: 0,
					paid: false,
					ys7Id: null
				},
				ys7s: [],
				schools: [],
				url: '/pc/live',
				initFee: null,
				laterFee: null
			},
			created: function () {
				var url = '/pc/school/all';
				var url2 = '/pc/ys7/all';

				if (/agent/.test(top.location.href)) {
					var agentId = top_params().id;
					url += '/' + agentId;
					url2 += '/' + agentId;


				}

				if (!/school/.test(top.location.href)) {
					axios.get(url).then(function (res) {
						this.schools = res.data;
					}.bind(this));

					axios.get(url2).then(function (res) {
						this.ys7s = res.data;
					}.bind(this));
				}

				this.init();
			},
			methods: {
				formatData: function (data) {
					if (data.initFee) this.initFee = data.initFee / 100;
					if (data.laterFee) this.laterFee = data.laterFee / 100;
				},
				fillData: function () {
					if (this.item.paid && ![this.initFee, this.laterFee, this.item.duration].every(function (it) {
						return it && parseFloat(it) > 0;
					})) {
						alert("请填写正确");
						throw '参数错误';
					}
					if (this.initFee) this.item.initFee = (this.initFee * 100).toFixed(0);
					if (this.laterFee) this.item.laterFee = (this.laterFee * 100).toFixed(0);
				}
			}
		}));

	</script>
</body>

</html>